export default {
    namespaced: true,
    actions: {

    },
    //准备mutations-用于操作数据（state）
    mutations: {
        ADDCART(state, value) {
            state.carList = value
        },
        PAY(state, value) {
            state.orderList = value
        },
        ADDADDRESS(state, value){
          state.userAddress.map((item)=>{
                if(value.isDefault){
                    item.isDefault=false
                }
            })
            state.userAddress.push(value)
        },
        ADDCHANGEADDRESS(state, value){
            state.userAddress=state.userAddress.map((item)=>{
                if(value.isDefault){
                    item.isDefault=false
                }
                return value.id===item.id?value:item
            })
        }
    },
    state: {
        carList: [],
        orderList: [],
        userAddress: [
            {
                id: 1001,
                name: "吴鸿卓",
                tel: "13227172517",
                province: '湖北省',
                city: '武汉市',
                county: "江夏区",
                addressDetail: "杨桥湖大道1号湖北经济学院",
                isDefault: true,
                areaCode:'420115',
            },
            {
                id: 1002,
                name: "张三",
                tel: "1322227217",
                province: '湖北省',
                city: '武汉市',
                county: "江夏区",
                addressDetail: "佛祖岭社区藏龙大道28号湖北城市建设职业技术学院",
                isDefault: false,
                areaCode:'420115',
            }
        ],
    },
    //准备getters-用于将state中的数据进行加工
    getters: {

    }
}